package com.link2room.rodimus.service;

import com.link2room.rodimus.dto.param.api.CouponConsumeParamDto;
import com.link2room.rodimus.dto.result.base.CouponConsumeDto;
import com.link2room.rodimus.dto.result.base.CouponConsumeTempDto;
import com.link2room.rodimus.entity.*;

import java.util.List;

/**
 * Created by LN on 2017/7/21.15:49
 */
public interface ICouponService {

    /**
     * 电子券购买详情
     */
    List<CouponDetailEntity> createNewCouponDetail(String orderNo, String lhotelGroupCode, String couponCode, String openid, Integer num, String saleType, String memberNo);

    /**
     * 生成月饼券码
     *
     * @return
     * @throws Exception
     */
    String generateNewCouponNo() throws Exception;

    /**
     * 生成月饼分享流水号
     *
     * @return
     */
    String generateCouponPresentNo() throws Exception;

    /**
     * 分享事件保存
     *
     * @param presentBaseEentity
     * @param cpdList
     * @param CouponDetailEntitys
     */
    void savePresent(CouponPresentBaseEntity presentBaseEentity, List<CouponPresentDetailEntity> cpdList, List<CouponDetailEntity> CouponDetailEntitys) throws Exception;

    String couponSign(String opennid, String couponPresentNo);

    /**
     * 检查是否
     *
     * @param presentNo
     * @param couponSign
     */
    void checkCouponPresent(String presentNo, String couponSign, String toUser) throws Exception;

    /**
     * 领券
     *
     * @param presentNo
     * @param openid
     */
    void doDraw(String presentNo, String openid, String remark) throws Exception;

    /**
     * 初始化电子券
     *
     * @param openid
     * @param saleType
     * @param fromUser
     * @return
     */
    CouponDetailEntity initNewCoupon(String couponCode, String lhotelGroupCode, String openid, String saleType, String fromUser);

    /**
     * 是否领取过电子券
     *
     * @param openid
     * @param couponPresentNo
     * @return
     */
    boolean hasPresentDrew(String openid, String couponPresentNo) throws Exception;

    /**
     * 初始化券消费记录
     *
     * @param goodCode
     * @param couponCode
     * @param memberNo
     * @param openid
     * @return
     */
    CouponConsumeBaseEntity intiConsumeBase(String lhotelGroupCode, String goodCode, String couponCode, String memberNo, String openid) throws Exception;

    /**
     * 保存券消费信息
     *
     * @param baseEntity
     * @param details
     */
    void saveConsumeInfo(CouponConsumeBaseEntity baseEntity, List<CouponConsumeDetailEntity> details, List<CouponDetailEntity> updateCouponDetails) throws Exception;

    /**
     * 发送重置赠送券延迟消息
     *
     * @param presentNo
     */
    void sendResetPresentCouponMsg(String presentNo);

    /**
     * 重置赠送券
     *
     * @param presentNo
     */
    void resetOresentCoupon(String presentNo) throws Exception;

    /**
     * 消费电子券
     * @return
     */
    CouponConsumeDto couponConsum(CouponConsumeParamDto paramDto) throws Exception;

    /**
     * jpa中 事务嵌套，mergelist 导致其他方法中 merge 提交不成功
     * @param paramDto
     * @return
     * @throws Exception
     */
    CouponConsumeTempDto couponConsumTemp(CouponConsumeParamDto paramDto) throws Exception;

    /**
     * 可用券统计
     * @param lhotelGroupCode
     * @param couponCode
     * @return
     */
    Long findCouponCount(String lhotelGroupCode, String couponCode, String openid) throws Exception;

	Long findCouponCountAll(String lhotelGroupCode, String couponCode, String openid) throws Exception;

	void coupenCodeCollarCoupen(String lhotelGroupCode, String couponCode, String couponCodeType);
}
